<?php

namespace IDock\Printer;

class BasePrinter
{
    public function toArray(): array
    {
        $objectVars = get_object_vars($this);

        foreach ($objectVars as &$objectVar) {
            if (is_object($objectVar) and ($objectVar instanceof BasePrinter)) {
                $objectVar = $objectVar->toArray();
            }
        }

        return $objectVars;
    }

    public function result():array
    {
        return $this->toArray();
    }
}